package com.hmall.service;

import com.hdmall.business.common.common.ServerResponse;
import com.hmall.mapper.DictionMapper;
import com.hmall.model.Diction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName constantService
 * @Description
 * @Author zhoutao
 * @Date 2018/12/5 13:05
 * @Version 2.0
 **/
@Service
public class ConstantService {

    @Autowired
    DictionMapper dictionMapper;

    public ServerResponse getIOSVersion(String type) {
        type = "ios_" + type;
        Diction diction = dictionMapper.selectByDictionKey(type);
        return ServerResponse.createBySuccess(diction);

    }

    public ServerResponse setIOSVersion(String type, String version, String check) {
        type = "ios_" + type;
        try {
            dictionMapper.updateByDitionKey(type, version, check);
        }catch (Exception e){
            e.printStackTrace();
        }
        return ServerResponse.createBySuccess("版本号设置成功");
    }

    public String getUrl(String type) {
        String url;
        switch (type){
            case "logisImg" :{
                url = "http://hd-yun.oss-cn-hangzhou.aliyuncs.com/imgupload/1547024150802.jpg?Expires=1862384143&OSSAccessKeyId=LTAI0AE4IXlOaSaX&Signature=XAtLKU8dKFnD64Wtgw6Bpzo%2BPk0%3D";
                break;
            }
            case "logisWord" :{
                url = "http://hd-yun.oss-cn-hangzhou.aliyuncs.com/imgupload/1547024393844.docx?Expires=1862384388&OSSAccessKeyId=LTAI0AE4IXlOaSaX&Signature=IxMnB56YYfBRtXA9FQMDdZBGC%2BU%3D";
                break;
            }
            case "licenseImg":{
                url = "http://hd-yun.oss-cn-hangzhou.aliyuncs.com/imgupload/1547024566784.jpg?Expires=1862384560&OSSAccessKeyId=LTAI0AE4IXlOaSaX&Signature=RVv90poeFYJIwB66y%2FiNZoTmsT8%3D";
                break;
            }
            case "taxCertImg":{
                url = "http://hd-yun.oss-cn-hangzhou.aliyuncs.com/imgupload/1547024609597.png?Expires=1862384600&OSSAccessKeyId=LTAI0AE4IXlOaSaX&Signature=fwAUc%2FFwEurTxZFOJDLCZSIpoog%3D";
                break;
            }
            case "authImg":{
                url = "http://hd-yun.oss-cn-hangzhou.aliyuncs.com/imgupload/1547024670457.png?Expires=1862384662&OSSAccessKeyId=LTAI0AE4IXlOaSaX&Signature=jAHOQ%2FJmp5H7oduWBqB4PXby3I8%3D";
                break;
            }
            case "authNoImg":{
                url = "http://hd-yun.oss-cn-hangzhou.aliyuncs.com/imgupload/1547024690223.png?Expires=1862384687&OSSAccessKeyId=LTAI0AE4IXlOaSaX&Signature=0buu2jDfDHFRTxGj4ep17azrhJU%3D";
                break;
            }
            case "authNoWord":{
                url = "http://huangyonghui.oss-cn-beijing.aliyuncs.com/imgupload/1528341626566.docx?Expires=1843701621&OSSAccessKeyId=LTAIp8OhI23AvQo5&Signature=sZGt3sj6i4%2FOSfjdRz75vQzLDSc%3D";
                break;
            }

            case "selfProxyImg":{
                url = "http://huangyonghui.oss-cn-beijing.aliyuncs.com/imgupload/1529035085278.png?Expires=1844395080&OSSAccessKeyId=LTAIp8OhI23AvQo5&Signature=QDMO4pwGrBXtqRhFcvZMPfMJD5c%3D";
                break;
            }

            case "regProtocol":{
                url = "http://hd-yun.oss-cn-hangzhou.aliyuncs.com/imgupload/1547023842373.html?Expires=1862383832&OSSAccessKeyId=LTAI0AE4IXlOaSaX&Signature=nwXQYawz2aNV2Co5VLC3cCnu4A8%3D";
                break;
            }

            case "monthPlanReview":{
                url = "http://huangyonghui.oss-cn-beijing.aliyuncs.com/imgupload/1534240538403.html?Expires=1849600532&OSSAccessKeyId=LTAIp8OhI23AvQo5&Signature=Fo2TV6AIgtv6shsJMB7OaRuHCNY%3D";
                break;
            }
            default: url = "请输入正确的类型";
                break;

        }
        return url;
    }
}
